package com.gg.fmallspringboot.controller;

import com.gg.fmallspringboot.entity.Category;
import com.gg.fmallspringboot.model.Result;
import com.gg.fmallspringboot.service.CategoryService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
@RequestMapping("/category")
public class CategoryController {

    private CategoryService categoryService;

    public CategoryController(CategoryService categoryService) {
        this.categoryService = categoryService;
    }

    @GetMapping("/list")
    public Result<Category> getCategoryList(){
        return categoryService.queryCategoryVo();
    }


    @GetMapping("/level")
    public Result<Category> getCategoryByLevel(){

        return categoryService.selectCategoryByLevel(1);
    }


}
